//
//  MazeView.h
//  Maze
//
//  Created by 奕 朱 on 11-3-30.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>

static const CGFloat kCellImageSize = 40;

static NSString *kWallImageName = @"block.png";
static NSString *kGroundImageName = @"ground.png";
static NSString *kGoalImageName = @"goal.png";
static NSString *kPlayerImageName = @"player.png";

enum {
	kCellTypeWall = 0,
	kCellTypeGround = 1,
	kCellTypeStart = 2,
	kCellTypeGoal = 3
};


@interface MazeView : UIView {

	NSUInteger _numOfHorizontalCells;
	
	NSUInteger _numOfVerticalCells;
	
	NSData *_cellData;
	
	UIImage *_worldImage;

	UIImage *_playerImage;
	
	CGPoint _startLocation;
	
	CGPoint _playerLocation;
	
}

@property NSUInteger numOfHorizontalCells;
@property NSUInteger numOfVerticalCells;
@property (retain) NSData *cellData;
@property (retain) UIImage *worldImage;
@property CGPoint startLocation;
@property CGPoint playerLocation;
@property (retain) UIImage *playerImage;

- (BOOL) loadFromContentsOfURL: (NSURL *) fileURL;

@end


@interface MazeView (Private)

- (void) parseLineString: (NSString *) lineString
				 writeTo: (uint8_t *) dstPtr;

- (void) createWorldImage;

- (NSArray *) loadCellImageArray;

- (CGPoint) findStartCell;

- (CGRect) rectForCell: (CGPoint) cellLocation;

@end

